<%= render :partial => 'spree/admin/shared/configuration_menu' %>

<h1 class="page-title "> <%= Spree.t("listing_store_credits") %></h1><br>

<table class="index">
  <thead>
    <tr>
      <th><%= Spree.t("user") %></th>
      <th><%= Spree.t("amount") %></th>
      <th><%= Spree.t("remaining_amount") %></th>
      <th><%= Spree.t("reason") %></th>
    </tr>
  </thead>
  <tbody>
    <% @store_credits.each do |store_credit|%>
      <tr id="<%= dom_id store_credit %>">
        <td><%= link_to store_credit.user.email, admin_user_url(store_credit.user) if store_credit.user.present? %></td>
        <td><%= number_to_currency store_credit.amount %></td>
        <td><%= number_to_currency store_credit.remaining_amount %></td>
        <td><%= store_credit.reason %></td>
        <td class="actions">
          <% if store_credit.remaining_amount > 0 %>
            <% if store_credit.amount == store_credit.remaining_amount %>
              <%= link_to_edit store_credit, :no_text => true %> &nbsp;
            <% else %>
              <%= Spree.t(:was_partially_used) %>
            <% end %>
            <%= link_to_delete store_credit, :no_text => true %>
          <% else %>
            <%= Spree.t(:was_fully_used) %>
          <% end %>
      </tr>
    <% end %>
    <% if @store_credits.empty? %>
      <tr><td colspan="4"><%= Spree.t(:none) %></td></tr>
    <% end %>
  </tbody>
</table>

<%= paginate @store_credits %>
